﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using SmartSpace.Packaging;
using SmartSpace.Core;
using SmartSapce.ServiceLocation;

namespace SmartSpace.WebApp._console.core
{
    public partial class org_member_import : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        #region 导入关联关系
        protected void _ctlBtnImportMember_Click(object sender, EventArgs e)
        {
            Stream stream = new MemoryStream(_ctlFileXmlMember.FileBytes);
            List<OrgMember> members = XMemberUtil.Load(stream);
            ICoreService service = ServiceLocator.Get<ICoreService>();

            foreach (var item in members)
            {
                service.AddMember(item.Org.Code, item.User.Account, item.IsMajor);
            }

            Response.Redirect(this._ctlLinkBack.NavigateUrl);
        }
        #endregion
    }
}